package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TLogin;
import com.ruoyi.system.service.ITLoginService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 注册Controller
 * 
 * @author ruoyi
 * @date 2022-10-17
 */
@RestController
@RequestMapping("/system/login")
public class TLoginController extends BaseController
{
    @Autowired
    private ITLoginService tLoginService;

//    /**
//     * 用户二维码
//     */
//    @GetMapping("/qrcode")
//    public String qrcode(HttpServletRequest request) {
//        return tLoginService.qrcode(request);
//
//    }



    /**
     * 查询注册列表
     */
    @PreAuthorize("@ss.hasPermi('system:login:list')")
    @GetMapping("/list")
    public TableDataInfo list(TLogin tLogin)
    {
        startPage();
        List<TLogin> list = tLoginService.selectTLoginList(tLogin);
        return getDataTable(list);
    }

    /**
     * 导出注册列表
     */
    @PreAuthorize("@ss.hasPermi('system:login:export')")
    @Log(title = "注册", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TLogin tLogin)
    {
        List<TLogin> list = tLoginService.selectTLoginList(tLogin);
        ExcelUtil<TLogin> util = new ExcelUtil<TLogin>(TLogin.class);
        util.exportExcel(response, list, "注册数据");
    }

    /**
     * 获取注册详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:login:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tLoginService.selectTLoginById(id));
    }

    /**
     * 新增注册
     */
    @PreAuthorize("@ss.hasPermi('system:login:add')")
    @Log(title = "注册", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TLogin tLogin)
    {
        return toAjax(tLoginService.insertTLogin(tLogin));
    }

    /**
     * 修改注册
     */
    @PreAuthorize("@ss.hasPermi('system:login:edit')")
    @Log(title = "注册", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TLogin tLogin)
    {
        return toAjax(tLoginService.updateTLogin(tLogin));
    }

    /**
     * 删除注册
     */
    @PreAuthorize("@ss.hasPermi('system:login:remove')")
    @Log(title = "注册", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tLoginService.deleteTLoginByIds(ids));
    }
}
